<script setup lang="ts">
import { ref } from 'vue'
import { timeStamp, timeFormat, regYuanToFen, toYuan } from '@/hooks/util'
import * as quotationRulesApi from '@/api/quotationRules'
import * as preQuotationApi from '@/api/preQuotation'
import { message } from 'ant-design-vue'
import MarkList from './MarkList.vue'

const myModal = ref()

let title = ref<string>('新增')

// 询价模式
let quotationMode = ref<number>(1)

// 切换询价模式
const selectQuotationMode = (e: any) => {
  console.log(e, 'e')
  quotationMode.value = e.target.value  
}
let rowInfo = ref<any>({})
let theType = ref<number>(1)
let selectedRobotId = ref<number>(0)
const showModal = (type: number, robotId: number, record: Object = {}) => {
  getCinemaLineList() // 院线列表

  matchChannelFlag.value = false
  alternativeChannelFlag.value = false
  fixedPriceFlag_2.value = true

  theType.value = type // 微信：1，闲鱼：3
  selectedRobotId.value = robotId
  rowInfo.value = record

  matchChannel.value = 6
  alternativeChannel.value = 3

  alternativeChannelList.value?.forEach(item => {
    item.able = false
    if (item.value == matchChannel.value) {
      item.able = true
    }
    if (item.value == 99) {
      item.able = true
    }
    // if (item.value == 7) {
    // }
  })
  channelList.value?.forEach(item => {
    item.able = false
    if (item.value == alternativeChannel.value) {
      item.able = true
    }
    if (item.value == 99) {
      item.able = true
    }
    // if (item.value == 7) {
    //   item.able = true
    // }
  })

  if (Object.keys(rowInfo.value).length > 0) {
    title.value = '编辑规则'

    console.log('rowInfo=', rowInfo.value)

    if (!rowInfo.value.cinemaList) {
      rowInfo.value.cinemaList = []
    }
    formState.value.cinemaNo = rowInfo.value.cinemaList.map(item => item.name)

    alternativeChannel.value = rowInfo.value.slaveMatchChannel
    matchChannel.value = rowInfo.value.matchChannel
    formState.value.finalPriceAdjustType = rowInfo.value.finalPriceAdjustType
    formState.value.isFixedPrice = rowInfo.value.enableLimitPrice

    alternativeChannelList.value?.forEach(item => {
      item.able = false
      if (item.value == matchChannel.value) {
        item.able = true
      }
      // if (item.value == 7) {
      //   item.able = true
      // }
    })
    channelList.value?.forEach(item => {
      item.able = false
      if (item.value == alternativeChannel.value) {
        item.able = true
      }
      // if (item.value == 7) {
      //   item.able = true
      // }
    })

    if (matchChannel.value == 99) {
      matchChannelFlag.value = true
      fixedPriceFlag_2.value = false
    }
    if (alternativeChannel.value == 99) {
      alternativeChannelFlag.value = true
      fixedPriceFlag_2.value = false
    }

    formState.value.name = rowInfo.value.name

    formState.value.sort = rowInfo.value.sort

    formState.value.lineArr = rowInfo.value.lineList.map((item: any) => {
      return {
        label: item.lineName,
        value: item.lineId,
      }
    })
    formState.value.ticketChannel = rowInfo.value.ticketChannel
    formState.value.quotationType = rowInfo.value.quotationType
    quotationMode.value = rowInfo.value.quotationMode
    formState.value.discount = Math.abs(toYuan(rowInfo.value.discount) as any)
    formState.value.percent = Math.abs(rowInfo.value.percent)

    if (Number(rowInfo.value.limitPrice) > 0) {
      formState.value.limitPrice = Number(toYuan(rowInfo.value.limitPrice))
      limitAddSubIndex.value = 0
    } else {
      formState.value.limitPrice = 0 - Number(toYuan(rowInfo.value.limitPrice))
      limitAddSubIndex.value = 1
    }
  } else {
    title.value = '新增规则'
  }

  myModal.value?.showModal()
}

const handleCancel = () => {
  formRef.value.resetFields()
  myModal.value.guanBiModal()
}

const handleSubmit = () => {
  formRef.value.validate().then(async () => {
    console.log('formState=', formState.value)
    const params = {
      channel: theType.value, // 闲鱼
      status: 1, // 0：关，1：开
      discount: regYuanToFen(Number(formState.value.discount), 100),
      name: formState.value.name,
      sort: formState.value.sort,
      percent: Number(formState.value.percent),
      quotationType: formState.value.quotationType,
      robotId: selectedRobotId.value,
      ticketChannel: formState.value.ticketChannel,
      quotationMode: quotationMode.value,
      lineList: formState.value.lineArr.map((item: any) => {
        return {
          lineId: item.value,
          lineName: item.label,
        }
      }),
      finalPriceAdjustType: formState.value.finalPriceAdjustType, // 报价调整类型
      matchChannel: matchChannel.value, // 首选
      slaveMatchChannel: alternativeChannel.value, // 备选
      enableLimitPrice: formState.value.isFixedPrice, // 是否启用限价
      cinemaList: formState.value.cinemaNo.map(item => {
        return {
          name: item,
        }
      }),
    }

    if (formState.value.quotationType == 2) {
      params.discount = 0 - params.discount
    }

    if (formState.value.quotationType == 4) {
      params.percent = 0 - params.percent
    }

    if (limitAddSubIndex.value == 0) {
      // 加法
      params.limitPrice = regYuanToFen(formState.value.limitPrice, 100)
    } else {
      params.limitPrice = regYuanToFen(formState.value.limitPrice, 100)
    }

    console.log('params=', params)

    // 编辑
    if (Object.keys(rowInfo.value).length > 0) {
      params.id = rowInfo.value.id
      try {
        let { state, message: msg } = await preQuotationApi.editSimpleQuotation(params)
        if (state === 200) {
          message.success('编辑成功')
          emit('refresh')
          handleCancel()
        } else {
          message.error(msg)
        }
      } catch (error) {
        message.error('网络请求连接失败~')
      }
    } else {
      // 新增
      try {
        let { state, message: msg } = await preQuotationApi.addSimpleQuotation(params)
        if (state === 200) {
          message.success('添加成功')
          emit('refresh')
          handleCancel()
        } else {
          message.error(msg)
        }
      } catch (error) {
        message.error('网络请求连接失败~')
      }
    }
  })
}

const emit = defineEmits<{
  refresh: []
}>()

defineExpose({
  showModal,
})

const formRef = ref()
const labelCol = {
  style: { width: '160px' },
}

interface FormState {
  name: string
  quotationType: number
  ticketChannel: number
  discount: number
  percent: number
  lineArr: Array<string>
  finalPriceAdjustType: string | number
  // alternativeChannel: number | string
  // channel: number | string
  isFixedPrice: number
  limitPrice: number
  cinemaNo: Array<any> // 排除影院
  sort: number
}

const formState = ref<FormState>({
  name: '',
  quotationType: 1,
  ticketChannel: 3,
  discount: 0,
  percent: 0,
  lineArr: [],
  finalPriceAdjustType: 0,
  // channel: 6,
  // alternativeChannel: 3,
  isFixedPrice: 1,
  limitPrice: 0,
  cinemaNo: [],
  sort: 0,
})

import type { Rule } from 'ant-design-vue/es/form'

let validateChangeBalanceLimit = async (rule: RuleObject, value: string) => {
  value = String(value)
  if (value == null || value.trim() === '') {
    return Promise.reject('金额不能为空')
  }
  // 使用正则表达式来验证金额格式，允许整数和小数点后两位
  const regex = /^\d+(\.\d{1,1})?$/
  if (!regex.test(value)) {
    return Promise.reject('请输入大于等于0的金额（整数或小数点后一位）')
  }

  // 将字符串转换为数字并检查是否大于0
  const amount = parseFloat(value)
  if (isNaN(amount) || amount < 0) {
    return Promise.reject('请输入大于等于0的金额')
  }

  // 如果一切正常，返回成功
  return Promise.resolve()
}

let validateChangeBalance = async (rule: RuleObject, value: string) => {
  value = String(value)
  if (value == null || value.trim() === '') {
    return Promise.reject('金额不能为空')
  }
  // 使用正则表达式来验证金额格式，允许整数和小数点后两位
  const regex = /^\d+(\.\d{1,1})?$/
  if (!regex.test(value)) {
    return Promise.reject('请输入大于等于0的金额（整数或小数点后一位）')
  }

  if (formState.value.quotationType == 1) {
    // 将字符串转换为数字并检查是否大于0
    const amount = parseFloat(value)
    if (isNaN(amount) || amount < 0) {
      return Promise.reject('请输入大于等于0的金额')
    }
  } else if (formState.value.quotationType == 2) {
    const amount = parseFloat(value)
    if (isNaN(amount) || amount > 1.5) {
      return Promise.reject('请输入不大于1.5的金额')
    }
  }

  // 如果一切正常，返回成功
  return Promise.resolve()
}
let validateChangeBalanceCopy = async (rule: RuleObject, value: string) => {
  value = String(value)
  if (value == null || value.trim() === '') {
    return Promise.reject('金额不能为空')
  }
  // 使用正则表达式来验证金额格式，仅允许整数
  const regex = /^\d+(\.\d{1,1})?$/
  if (!regex.test(value)) {
    return Promise.reject('请输入大于等于0的金额（整数或小数点后一位）')
  }

  if (formState.value.quotationType == 4) {
    // 将字符串转换为数字并检查是否大于0
    const amount = parseFloat(value)
    if (isNaN(amount) || amount > 5) {
      return Promise.reject('请输入不大于5的整数比例')
    }
  } else {
    const amount = parseFloat(value)
    if (isNaN(amount) || amount < 0) {
      return Promise.reject('请输入大于等于0的比例')
    }
  }

  // 如果一切正常，返回成功
  return Promise.resolve()
}

let sortFlag = ref(true)
let validateSort = async (rule: RuleObject, value: string) => {
  value = String(value).trim()
  if (value === '') {
    sortFlag.value = false
    return Promise.reject('数值不能为空')
  }

  // 使用正则表达式来验证正整数格式
  const regex = /^\d+$/
  if (!regex.test(value)) {
    sortFlag.value = false
    return Promise.reject('请输入大于等于0的正整数')
  }

  const amount = parseInt(value, 10) // 使用parseInt确保转换为整数
  if (isNaN(amount) || amount < 0 || amount > 999) {
    sortFlag.value = false
    return Promise.reject('请输入0到999之间的正整数')
  }

  // 如果一切正常，返回成功
  sortFlag.value = true
  return Promise.resolve()
}

const rules: Record<string, Rule[]> = {
  name: [{ required: true, message: '必填项', trigger: 'blur' }],
  lineArr: [{ required: true, message: '必填项', trigger: 'blur' }],
  limitPrice: [{ required: true, validator: validateChangeBalanceLimit, trigger: 'blur' }],
  percent: [{ required: true, validator: validateChangeBalanceCopy, trigger: 'blur' }],
  discount: [{ required: true, validator: validateChangeBalance, trigger: 'blur' }],
  sort: [{ required: true, validator: validateSort, trigger: 'blur' }],
}

// 院线
import type { SelectProps } from 'ant-design-vue'
const cinemaLineList = ref<SelectProps['options']>([])
const getCinemaLineList = async () => {
  try {
    const { state, data, message: msg } = await quotationRulesApi.getCinemaLineList()
    if (state === 200) {
      cinemaLineList.value = data.map((item: any) => {
        return {
          label: item.cinemaLineName,
          value: item.id,
        }
      })
    } else {
      message.error(msg)
    }
  } catch (error) {
    message.error('网络请求连接失败~')
  }
}

let okCinemaLine = ref<Array<any>>([])
const selectCinemaLine = (selectValue: any, option: any) => {
  okCinemaLine.value = selectValue
  formState.value.lineArr = option
  console.log('院线=', formState.value.lineArr)
}

// 所有select的模糊搜索
const filterOption = (input: string, option: any) => {
  return option.label.indexOf(input) >= 0
}

const quotationTypeList = ref<SelectProps['options']>([
  {
    label: '加法',
    value: 1,
  },
  {
    label: '减法',
    value: 2,
  },
  {
    label: '比例（百分比加法）',
    value: 3,
  },
  {
    label: '比例（百分比减法）',
    value: 4,
  },
])

const ticketChannelList = ref<SelectProps['options']>([
  {
    label: '动态渠道',
    value: 99,
    able: false,
  },
  {
    label: '麻花电影票',
    value: 3,
    able: false,
  },
  {
    label: '守兔一口价',
    value: 11,
    able: false,
  },
  {
    label: '守兔电影票',
    value: 7,
    able: true,
  },
  {
    label: '芒果电影票',
    value: 5,
    able: false,
  },
  {
    label: '哈哈电影快票',
    value: 9,
    able: false,
  },
  {
    label: '星驰电影票',
    value: 8,
    able: false,
  },
  {
    label: '影划算电影票',
    value: 10,
    able: false,
  },
])

// 处理最终报价调整类型
const finalPriceAdjustTypeList = ref<SelectProps['options']>([
  {
    label: '四舍五入到整数元',
    value: 1,
  },
  {
    label: '四舍五入到元-0.1',
    value: 2,
  },
  {
    label: '到0.5/整数元',
    value: 3,
  },
  {
    label: '不调整',
    value: 0,
  },
])

// 首选渠道
let matchChannel = ref<number | string>(6)
const channelList = ref<SelectProps['options']>([
  {
    label: '动态渠道',
    value: 99,
    able: false,
  },
  {
    label: '麻花电影票（可限价）',
    value: 3,
    able: false,
  },
  {
    label: '芒果电影票（一口价）',
    value: 5,
    able: false,
  },
  {
    label: '星驰电影票（一口价）',
    value: 8,
    able: false,
  },
  {
    label: '哈哈电影票',
    value: 6,
    able: false,
  },
  {
    label: '守兔电影票（一口价）',
    value: 11,
    able: false,
  },
  {
    label: '守兔电影票（可限价）',
    value: 7,
    // able: true,
    able: false,
  },
  {
    label: '哈哈电影快票（固定9折）',
    value: 9,
    able: false,
  },
  {
    label: '影划算电影票（可限价）',
    value: 10,
    able: false,
  },
])
let fixedPriceFlag = ref<boolean>(false)
let isFixedPrice = ref<number>(1)
const selectChannel = (e: any) => {
  console.log('首选渠道=', e)
  matchChannel.value = e
  if (e == 3 || e == 8 || e == 7 || e == 10) {
    fixedPriceFlag.value = true
  } else {
    fixedPriceFlag.value = false
  }
  alternativeChannelList.value?.forEach(item => {
    item.able = false
    if (item.value == e) {
      item.able = true
    }
    // if (item.value == 7) {
    //   item.able = true
    // }
    if (item.value == 99) {
      item.able = true
    }
  })
  // channelList.value?.forEach(item => {
  //   if (item.value == 7) {
  //     item.able = true
  //   }
  // })
}

// 备选渠道 - 新
let alternativeChannel = ref<number | string>(3)
let fixedPriceFlag_2 = ref<boolean>(true)
const alternativeChannelList = ref<SelectProps['options']>([
  {
    label: '动态渠道',
    value: 99,
    able: false,
  },
  {
    label: '不使用',
    value: 0,
    able: false,
  },
  {
    label: '麻花电影票（可限价）',
    value: 3,
    able: false,
  },
  {
    label: '芒果电影票（一口价）',
    value: 5,
    able: false,
  },
  {
    label: '星驰电影票（一口价）',
    value: 8,
    able: false,
  },
  {
    label: '哈哈电影票',
    value: 6,
    able: false,
  },
  {
    label: '守兔电影票（一口价）',
    value: 11,
    able: false,
  },
  {
    label: '守兔电影票（可限价）',
    value: 7,
    // able: true,
    able: false,
  },
  {
    label: '哈哈电影快票（固定9折）',
    value: 9,
    able: false,
  },
  {
    label: '影划算电影票（可限价）',
    value: 10,
    able: false,
  },
])
const selectAlternativeChannel = (e: any) => {
  console.log('备选渠道=', e)
  alternativeChannel.value = e
  if (e == 3 || e == 8 || e == 7 || e == 10) {
    fixedPriceFlag_2.value = true
  } else {
    fixedPriceFlag_2.value = false
  }
  channelList.value?.forEach(item => {
    item.able = false
    if (item.value == e) {
      item.able = true
    }
    // if (item.value == 7) {
    //   item.able = true
    // }
    if (item.value == 99) {
      item.able = true
    }
  })
  // alternativeChannelList.value?.forEach(item => {
  //   if (item.value == 7) {
  //     item.able = true
  //   }
  // })
}

// 限价 - 加减符号
let limitAddSubIndex = ref<number>(0)
const limitAddSubList = reactive([
  {
    label: '+',
    value: 0,
  },
  // {
  //   label: '-',
  //   value: 1,
  // },
])
const limitOkAddSubType = (index: number) => {
  limitAddSubIndex.value = index
}

// 排除影院
const getCinemaNo = (list: any) => {
  console.log('排除影院=', list)
  formState.value.cinemaNo = list
}

let matchChannelFlag = ref(false)
let alternativeChannelFlag = ref(false)
let okTicketChannel = ref<string | number>('')
const selectTicketChannel = (e: any) => {
  console.log('e=', e)
  okTicketChannel.value = e

  if (e == 99) {
    alternativeChannel.value = 99
    matchChannel.value = 99
    matchChannelFlag.value = true
    alternativeChannelFlag.value = true
    fixedPriceFlag_2.value = false
    fixedPriceFlag.value = false

    // console.log('fixedPriceFlag=', fixedPriceFlag.value)
  } else {
    matchChannelFlag.value = false
    alternativeChannelFlag.value = false
    fixedPriceFlag_2.value = true

    matchChannel.value = e
    alternativeChannel.value = 0

    alternativeChannelList.value?.forEach(item => {
      item.able = false
      if (item.value == 99) {
        item.able = true
      }
      if (item.value == e) {
        item.able = true
      }
    })
    channelList.value?.forEach(item => {
      item.able = false
      if (item.value == 99) {
        item.able = true
      }
    })
  }
}
</script>

<template>
  <MyModal ref="myModal" :title="title" :width="650" @cancelModal="handleCancel">
    <template #content>
      <div style="overflow-y: auto; max-height: 600px">
        <a-form ref="formRef" :label-col="labelCol" :model="formState" :rules="rules">
          <a-form-item name="name" label="规则名称">
            <a-input placeholder="规则名称" v-model:value="formState.name"></a-input>
          </a-form-item>

          <a-form-item name="sort" label="规则权重">
            <template #help v-if="sortFlag">
              数字越大越优先，相同权重时优先使用最新添加的规则
            </template>
            <a-input-number
              placeholder="规则权重"
              v-model:value="formState.sort"
              style="width: 320px; margin: 4px 0"
            ></a-input-number>
          </a-form-item>

          <a-form-item label="包含院线" name="lineArr">
            <a-select
              placeholder="请选择包含的院线"
              mode="multiple"
              show-search
              :options="cinemaLineList"
              :filter-option="filterOption"
              v-model:value="formState.lineArr"
              @change="selectCinemaLine"
            >
              <a-select-option
                v-for="(item, index) in cinemaLineList"
                :key="index"
                :value="item.value"
              >
                {{ item.label }}
              </a-select-option>
            </a-select>
          </a-form-item>

          <a-form-item name="cinemaNo" label="排除影院">
            <!-- <a-input placeholder="可以是空的" v-model:value="formState.cinemaNo"></a-input> -->
            <MarkList
              @okList="getCinemaNo"
              v-if="formState.cinemaNo.length > 0"
              :list="formState.cinemaNo"
            ></MarkList>
            <MarkList @okList="getCinemaNo" v-else :list="formState.cinemaNo"></MarkList>
          </a-form-item>

          <a-form-item name="cinemaNo" label="报价出票模式">
            <!-- <a-input placeholder="可以是空的" v-model:value="formState.cinemaNo"></a-input> -->
            <a-radio-group v-model:value="quotationMode" @change="selectQuotationMode">
              <a-radio :value="2">一口价</a-radio>
              <a-radio :value="1">预估限价</a-radio>
            </a-radio-group>
            <a-popover color="black">
              <template #content>
                <div style="color: #fff">
                  <div>
                    预估限价：基于历史成交数据、市场供需关系、场次信息，给出预估价格，可在预估基础上设置报价和限价
                  </div>
                  <div>一口价：联动多供应平台，一口价成交，成功率高，溢价包赔付</div>
                </div>
              </template>
              <QuestionCircleOutlined style="color: red; font-size: 18px; line-height: inherit" />
            </a-popover>
          </a-form-item>

          <!-- <a-form-item label="询价渠道" name="ticketChannel">
            <a-select
              v-model:value="formState.ticketChannel"
              placeholder="渠道"
              style="width: 320px"
              @change="selectTicketChannel"
            >
              <a-select-option
                v-for="(item, index) in ticketChannelList"
                :key="index"
                :value="item.value"
                :disabled="item.able"
              >
                {{ item.label }}
              </a-select-option>
            </a-select>
          </a-form-item> -->

          <a-form-item label="报价方式" name="quotationType">
            <a-select
              v-model:value="formState.quotationType"
              placeholder="报价方式"
              style="width: 320px"
            >
              <a-select-option
                v-for="(item, index) in quotationTypeList"
                :key="index"
                :value="item.value"
              >
                {{ item.label }}
              </a-select-option>
            </a-select>
          </a-form-item>

          <!-- 限价 -->
          <a-form-item name="limitPrice" label="单张限价" v-if="quotationMode == 1">
            <a-input
              v-model:value="formState.limitPrice"
              placeholder=""
              style="width: 318px; height: 32px"
            >
              <template #addonBefore>
                预估成本
                <span style="color: red; margin-left: 5px">+</span>
              </template>
              <template #suffix>元</template>
            </a-input>
          </a-form-item>

          <a-form-item name="discount" label="报价金额" v-if="formState.quotationType == 1">
            <a-input style="width: 318px" v-model:value="formState.discount" addon-after="元">
              <template #addonBefore>
                预估成本
                <span style="color: red; margin-left: 5px">+</span>
              </template>
            </a-input>
          </a-form-item>

          <a-form-item name="discount" label="报价金额" v-if="formState.quotationType == 2">
            <a-input style="width: 318px" v-model:value="formState.discount" addon-after="元">
              <template #addonBefore>
                预估成本
                <span style="color: red; margin-left: 5px">—</span>
              </template>
            </a-input>
          </a-form-item>

          <a-form-item name="percent" label="报价金额" v-if="formState.quotationType == 3">
            <a-input style="width: 318px" v-model:value="formState.percent" addon-after="% ）">
              <template #addonBefore>
                预估成本
                <span style="color: red; margin-left: 5px">x</span>
                （ 1 +
              </template>
            </a-input>
          </a-form-item>

          <a-form-item name="percent" label="报价金额" v-if="formState.quotationType == 4">
            <a-input style="width: 318px" v-model:value="formState.percent" addon-after="% ）">
              <template #addonBefore>
                预估成本
                <span style="color: red; margin-left: 5px">x</span>
                （ 1 -
              </template>
            </a-input>
          </a-form-item>

          <a-form-item name="finalPriceAdjustType">
            <template #label>
              <span style="margin-left: 15px">报价调整类型</span>
            </template>
            <a-select
              v-model:value="formState.finalPriceAdjustType"
              placeholder="请选择"
              style="width: 318px"
            >
              <a-select-option
                v-for="(item, index) in finalPriceAdjustTypeList"
                :key="index"
                :value="item.value"
              >
                {{ item.label }}
              </a-select-option>
            </a-select>
          </a-form-item>

          <!-- <a-form-item name="matchChannel" label="首选供应渠道">
            <template #help>
              <span v-if="matchChannel == 3" style="color: #bfbfbf">
                支持限价，你的出票成本=供应商中标价+供应商中标价*3%，手续费为供应渠道收取，票达人平台不收取任何订单手续费
              </span>
              <span v-if="matchChannel == 10" style="color: #bfbfbf">
                支持限价，你的出票成本=供应商中标价+供应商中标价*3%，手续费为供应渠道收取，票达人平台不收取任何订单手续费
              </span>
              <span v-else-if="matchChannel == 5" style="color: #bfbfbf">
                出票成本=预估出票价
              </span>
              <span v-else-if="matchChannel == 7" style="color: #bfbfbf">
                支持限价，你的出票成本=供应商中标价+供应商中标价*3%，手续费为供应渠道收取，票达人平台不收取任何订单手续费
              </span>
              <span v-else-if="matchChannel == 11" style="color: #bfbfbf">
                你的出票成本=预估出票价
              </span>
              <span v-else-if="matchChannel == 9" style="color: #bfbfbf">
                你的出票成本=猫淘价（原价）*90%
              </span>
              <span v-else-if="matchChannel == 6" style="color: #bfbfbf">
                不支持限价，你的出票成本=供应商中标价+原价*3%，手续费为供应渠道收取，票达人平台不收取任何订单手续费
              </span>
              <span v-else-if="matchChannel == 8" style="color: #bfbfbf">
                你的出票成本=预估出票价
              </span>
              <span v-else-if="matchChannel == 99" style="color: #bfbfbf">
                限价生效，溢价包赔付(成交价>限价)
              </span>
            </template>
            <a-select
              v-model:value="matchChannel"
              placeholder="请选择"
              @change="selectChannel"
              style="width: 300px"
              allowClear
              :disabled="matchChannelFlag"
            >
              <a-select-option
                v-for="(item, index) in channelList"
                :key="index"
                :value="item.value"
                :disabled="item.able"
              >
                {{ item.label }}
              </a-select-option>
            </a-select>
          </a-form-item> -->

          <!-- <a-form-item name="alternativeChannel" label="备选供应渠道">
            <template #help>
              <span v-if="alternativeChannel == 3" style="color: #bfbfbf">
                支持限价，你的出票成本=供应商中标价+供应商中标价*3%，手续费为供应渠道收取，票达人平台不收取任何订单手续费
              </span>
              <span v-if="alternativeChannel == 10" style="color: #bfbfbf">
                支持限价，你的出票成本=供应商中标价+供应商中标价*3%，手续费为供应渠道收取，票达人平台不收取任何订单手续费
              </span>
              <span v-else-if="alternativeChannel == 5" style="color: #bfbfbf">
                出票成本=预估出票价
              </span>
              <span v-else-if="alternativeChannel == 7" style="color: #bfbfbf">
                支持限价，你的出票成本=供应商中标价+供应商中标价*3%，手续费为供应渠道收取，票达人平台不收取任何订单手续费
              </span>
              <span v-else-if="alternativeChannel == 11" style="color: #bfbfbf">
                你的出票成本=预估出票价
              </span>
              <span v-else-if="alternativeChannel == 9" style="color: #bfbfbf">
                你的出票成本=猫淘价（原价）*90%
              </span>
              <span v-else-if="alternativeChannel == 6" style="color: #bfbfbf">
                不支持限价，你的出票成本=供应商中标价+原价*3%，手续费为供应渠道收取，票达人平台不收取任何订单手续费
              </span>
              <span v-else-if="alternativeChannel == 8" style="color: #bfbfbf">
                你的出票成本=预估出票价
              </span>
              <span v-else-if="matchChannel == 99" style="color: #bfbfbf">
                限价生效，溢价包赔付(成交价>限价)
              </span>
            </template>
            <a-select
              v-model:value="alternativeChannel"
              placeholder="请选择"
              @change="selectAlternativeChannel"
              style="width: 300px"
              allowClear
              :disabled="alternativeChannelFlag"
            >
              <a-select-option
                v-for="(item, index) in alternativeChannelList"
                :key="index"
                :value="item.value"
                :disabled="item.able"
              >
                {{ item.label }}
              </a-select-option>
            </a-select>
          </a-form-item> -->

          <a-form-item
            name="isFixedPrice"
            label="是否限价"
            
            v-if="quotationMode == 1"
          >
          <!-- fixedPriceFlag || fixedPriceFlag_2 ||  -->
            <a-radio-group v-model:value="formState.isFixedPrice" style="margin-top: 5px">
              <a-radio :value="1">启用限价</a-radio>
              <a-radio :value="0">不启用限价</a-radio>
            </a-radio-group>
          </a-form-item>
        </a-form>
      </div>
      <div class="footBtn">
        <a-button style="margin-right: 5px" @click="handleCancel">取消</a-button>
        <a-button type="primary" @click="handleSubmit">确定</a-button>
      </div>
    </template>
  </MyModal>
</template>

<style lang="less" scoped>
.footBtn {
  text-align: right;
  margin-top: 10px;
  border-top: 1px solid #f0f0f0;
  padding-top: 10px;
}

input {
  width: 320px;
}

/deep/ .ant-select-selector {
  width: 320px;
}

.active {
  background: #1890ff;
  color: #fff;
}

.active-red {
  background: red;
  color: #fff;
}
</style>
